package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Map;

import java.util.HashMap;
import java.util.List;

public interface UserDao {

    @Select("select * from t_user where username = #{username}")
    public User findByUsername(String username);

    @Update("UPDATE t_user set password = #{password} where username= #{name}")
    public void set(Map hashMap);

    public void add(User user);

    void setUserAndRole(HashMap<String, Integer> map);

    Page<CheckGroup> findByCondition(String queryString);

    @Select("select * from t_user where id=#{id}")
    User findById(Integer id);

    @Select("select role_id from t_user_role where user_id=#{id}")
    List<Integer> findRoleIdsByUserId(Integer id);

    void edit(User user);

    @Delete("delete from t_user_role where user_id = #{id}")
    void deleteAssocication(Integer id);

    @Delete("delete from t_user where id=#{id}")
    void deleteById(Integer id);
}
